// es2017
// ========Object.values
const obj = {
  name: 'cuvee',
  age: 30,
};

console.log(Object.values(obj));

// ========Object.entries
console.log(Object.entries(obj));

console.log(new Map(Object.entries(obj)));

// ========Object.getOwnPropertyDescriptors 主要配合getter和setter去使用
const p1 = {
  firstName: 'zaiyong',
  lastName: 'cui',
  get fullName() {
    return this.firstName + ' ' + this.lastName;
  },
};

// Object.assign没有复制对象的描述符。这儿只是将full当做普通属性复制了
const p2 = Object.assign({}, p1);

p2.firstName = 'cuvee';
console.log(p2);
console.log(p1.fullName);
console.log(p2.fullName);

const descriptors = Object.getOwnPropertyDescriptors(p1);

const p3 = Object.defineProperties({}, descriptors);

console.log(p3);

p3.firstName = 'cuvee';
console.log(p3.fullName);

// ============String.prototype.padStart String.prototype.padEnd
const language = {
  html: 5,
  css: 16,
  javascript: 128,
};

for (const [name, count] of Object.entries(language)) {
  console.log(name, count);
}

for (const [name, count] of Object.entries(language)) {
  console.log(`${name.padEnd(16, '-')}|${count.toString().padStart(3, '0')}`);
}

// ===========,尾调
const arr = [1, 2, 3];

// ==========Async/await
